package com.applet.mallappletbackstage.service.impl;

import com.applet.mallappletbackstage.entity.SkillsCertificate;
import com.applet.mallappletbackstage.mapper.SkillsCertificateMapper;
import com.applet.mallappletbackstage.service.SkillsCertificateService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author X
 * @since 2020-08-17
 */
@Service
public class SkillsCertificateServiceImpl extends ServiceImpl<SkillsCertificateMapper, SkillsCertificate> implements SkillsCertificateService {

    /***
     * 查询该用户的技能证书
     * @param openid
     * @return
     */
    @Override
    public List<SkillsCertificate> getSkills(String openid) {
        QueryWrapper<SkillsCertificate> skillsCertificateQueryWrapper = new QueryWrapper<>();
        skillsCertificateQueryWrapper.eq("open_id",openid);
        List<SkillsCertificate> skillsCertificates = baseMapper.selectList(skillsCertificateQueryWrapper);
        return skillsCertificates;
    }

    /***
     * 删除职业证书
     * @param id
     * @return
     */
    @Override
    public int deleteSkill(String id) {
        QueryWrapper<SkillsCertificate> skillsCertificateQueryWrapper = new QueryWrapper<>();
        skillsCertificateQueryWrapper.eq("id",id);
        return baseMapper.delete(skillsCertificateQueryWrapper);
    }
}
